#https://rffanlab.com/archives/622 https://blog.csdn.net/nyist_zxp/article/details/107597626
CURRENTPATH=$(readlink -f "$0")
CUR=`pwd`
echo "当前脚本位置。。。。"${CURRENTPATH}
echo "..."${CUR}
DIR=$( dirname "$(readlink -f  ${BASH_SOURCE[0]})" )
echo ${DIR}
#当前脚本上一层路径
PARENTPATH=$(dirname ${DIR})
echo y | sudo apt-get install gnupg2
echo y | sudo apt-get install expect
if [[ ! -z $1 ]] && [[ -d $1 ]] && [[ -z ${unline_path} ]]
then
PREHOME=$1
elif [[ ! -z ${unline_path} ]]
then
PREHOME=${unline_path}
else
PREHOME=${HOME}"/unline"
fi
if [[ ! -d ${PREHOME}/gpg/.gnupg ]]
then
#   expect ${DIR}/init.expect
  gpg --import --pinentry-mode loopback --batch --passphrase QQ15996779085 ${PREHOME}/gpg/private-file.key
  if [[ ! -d ${PREHOME}/gpg ]]
  then
    mkdir -p ${PREHOME}/gpg
    cp -r ${HOME}/.gnupg ${PREHOME}/gpg/
  fi
else
  cp -r ${PREHOME}/gpg/.gnupg ${HOME}/
fi
sudo chown -R ${USER}:${USER} ${HOME}/.gnupg
# 临时模拟maven打包
if [[ "$1" == "gpg" ]]
then
  export JAVA_HOME=/opt/soft/java/jdk8
  /opt/soft/maven/bin/mvn clean install -f ${DIR}/pom.xml -Dgpg.passphrase=zxhtom
fi
if [[ -d ${DIR}/target ]]
then
rm -rf ${DIR}/target
fi
